home *** CD-ROM | disk | FTP | other *** search
- #include <Scrap.h>
- #include <OpenTransport.h>
- #include <OpenTptInternet.h>
- #include <OSUtils.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <stdarg.h>
- #include <string.h>
- #include <Sound.h>
-
-
- void main( void )
- {
-
- OSStatus *err;
- char ip[15];
-
- unsigned short counter;
- Boolean end = false;
-
- InetInterfaceInfo *info;
-
-
- err = malloc(sizeof(OSStatus));
- info = malloc(sizeof(InetInterfaceInfo));
-
-
- //InitOT
- if( InitOpenTransport() != kOTNoError )
- {
- SysBeep(30);
- ExitToShell();
- }
-
- OTOpenInternetServices ( kDefaultInternetServicesPath, 0, err);
-
- //beep at user if there is an error, and quit
- if( *err != kOTNoError )
- {
- SysBeep(30);
- SysBeep(30);
- ExitToShell();
- }
-
- //Get your IP and put it in the string IP.
- OTInetGetInterfaceInfo( info, kDefaultInetInterface );
-
- OTInetHostToString( info->fAddress, ip );
-
-
- counter = 0;
-
- //make sure there are no weird chars
- while( !end )
- {
-
- switch( ip[counter] )
- {
-
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- case '.':
- counter++;
- if( counter == 15 )
- end = true;
- break;
- default:
- end = true;//so you will end the counter so it will end the for statement, and then you will know the string length is 1 less then the counter.
- break;
- }
-
- }
-
- ZeroScrap();
- PutScrap( counter, 'TEXT', ip );
-
- ExitToShell();
-
- }
-
-
-
-
-